package com.ruoyi.web.controller.system.client.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.client.domain.ServiceClientComplaint;
import com.ruoyi.system.client.service.IServiceClientComplaintService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户投诉Controller
 * 
 * @author Administrator
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/client/complaint")
public class ServiceClientComplaintController extends BaseController
{
    private String prefix = "client/complaint";

    @Autowired
    private IServiceClientComplaintService serviceClientComplaintService;

    @RequiresPermissions("client:complaint:view")
    @GetMapping()
    public String complaint()
    {
        return prefix + "/complaint";
    }

    /**
     * 查询客户投诉列表
     */
    @RequiresPermissions("client:complaint:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ServiceClientComplaint serviceClientComplaint)
    {
        startPage();
        List<ServiceClientComplaint> list = serviceClientComplaintService.selectServiceClientComplaintList(serviceClientComplaint);
        return getDataTable(list);
    }

    /**
     * 导出客户投诉列表
     */
    @RequiresPermissions("client:complaint:export")
    @Log(title = "客户投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ServiceClientComplaint serviceClientComplaint)
    {
        List<ServiceClientComplaint> list = serviceClientComplaintService.selectServiceClientComplaintList(serviceClientComplaint);
        ExcelUtil<ServiceClientComplaint> util = new ExcelUtil<ServiceClientComplaint>(ServiceClientComplaint.class);
        return util.exportExcel(list, "complaint");
    }

    /**
     * 新增客户投诉
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客户投诉
     */
    @RequiresPermissions("client:complaint:add")
    @Log(title = "客户投诉", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ServiceClientComplaint serviceClientComplaint)
    {
        return toAjax(serviceClientComplaintService.insertServiceClientComplaint(serviceClientComplaint));
    }

    /**
     * 修改客户投诉
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ServiceClientComplaint serviceClientComplaint = serviceClientComplaintService.selectServiceClientComplaintById(id);
        mmap.put("serviceClientComplaint", serviceClientComplaint);
        return prefix + "/edit";
    }

    /**
     * 修改保存客户投诉
     */
    @RequiresPermissions("client:complaint:edit")
    @Log(title = "客户投诉", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ServiceClientComplaint serviceClientComplaint)
    {
        return toAjax(serviceClientComplaintService.updateServiceClientComplaint(serviceClientComplaint));
    }

    /**
     * 删除客户投诉
     */
    @RequiresPermissions("client:complaint:remove")
    @Log(title = "客户投诉", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(serviceClientComplaintService.deleteServiceClientComplaintByIds(ids));
    }
}
